/**
 * Created with  SublimeText
 * @Author:      Lyle
 * @DateTime:    2017-06-07 13:20:33
 * @Description: 业务相关过滤数据领域
 */

import globalMixin from './globalMixin'

var filterDataPartMixin = {

    mixins: [globalMixin],

    methods: {

        filterDataPartMixin_ReplaceNeedAccessURL(url) {
            if (Env == 'dev' && url) {                
                url = url.replace(new RegExp("^https?://[\\w-.]+(:\\d+)?", "i").exec(url)[0], Domain);
            }
            /*  
                else if (util.queryString('mock')) {
                    url = url.replace(new RegExp("^https?://[\\w-.]+(:\\d+)?(.*)show_private_photo", "i").exec(url)[0], seajs.data.vars.apiAccessUrl + 'show_private_photo');
                }
            */
            return url;
        },

        filterDataPartMixin_ReplacePrivatePhotos(data) {
            if (Env == 'dev' && data.private_pictures) {
                let privates = data.private_pictures;
                for (let i in privates) {
                    privates[i].icon = this.filterDataPartMixin_ReplaceNeedAccessURL(privates[i].icon);
                    privates[i].picture = this.filterDataPartMixin_ReplaceNeedAccessURL(privates[i].picture);
                }
                data.private_pictures = privates;
            }
            return data;
        },
    }

}

export default filterDataPartMixin;
